#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_btn_input_clicked()
{
    QString text = "我";
    if(ui->rb_man->isChecked())
        text += "是男的";
    else if(ui->rb_women->isChecked())
        text += "是女的";
    else
        text +="的性别不透露，谢谢";

    text += "\n我平时喜欢：";

    if(ui->cb_cartoon->isChecked())
    {
        text += ui->cb_cartoon->text();
        text += "，";
    }
    if(ui->cb_game->checkState()==2)
    {
        text += ui->cb_game->text();
        text += "，";
    }

    if(ui->cb_swim->isChecked())
    {
        text += ui->cb_swim->text();
        text += "，";
    }

    if(ui->cb_read->isChecked())
    {
        text += ui->cb_read->text();
        text += "，";
    }

    if(ui->cb_play_basketball->isChecked())
    {
        text += ui->cb_play_basketball->text();
        text += "，";
    }

    int pos = text.lastIndexOf("，");
    text.replace(pos,1,"。");

    ui->textBrowser->setText(text);

}


void MainWindow::on_btn_clear_clicked()
{
    ui->textBrowser->clear();

    ui->rb_man->setAutoExclusive(false);
    ui->rb_man->setChecked(false);
    ui->rb_man->setAutoExclusive(true);

    ui->rb_women->setAutoExclusive(false);
    ui->rb_women->setChecked(false);
    ui->rb_women->setAutoExclusive(true);

    ui->cb_cartoon->setChecked(false);
    ui->cb_game->setChecked(false);
    ui->cb_play_basketball->setChecked(false);
    ui->cb_read->setChecked(false);
    ui->cb_swim->setChecked(false);
}

